package Year21_Month11.day1105;
import java.util.Scanner;

public class Main {
    //首先创建二叉树的节点
    public class BTNode{
        BTNode left;
        BTNode right;
        char val;
        public BTNode(char val){
            this.val = val;
        }
    }

    //然后开始准备构建二叉树
    int index = 0;//初始化下标
    public BTNode creatTree(char[] arr,char key){
        BTNode root = null;
        while(index < arr.length && arr[index] != key){
            root = new BTNode(arr[index]);

            index++;
            root.left = creatTree(arr,key);

            index++;
            root.right = creatTree(arr,key);
        }
        return root;
    }

    public void inOrder(BTNode root){
        if(root == null){
            return;
        }
        inOrder(root.left);
        System.out.print(root.val + " ");
        inOrder(root.right);
    }
    String s = null;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Main main = new Main();
        String s = sc.nextLine();
        char[] arr = s.toCharArray();
        BTNode root = main.creatTree(arr,'#');
        main.inOrder(root);
    }
}
